package com.ruoyi.project.module.propertyConstraint.controller;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.module.propertyConstraint.processor.model.PropConstraintVO;
import com.ruoyi.project.module.propertyConstraint.processor.scan.PropConstraint;
import com.ruoyi.project.module.propertyConstraint.processor.scan.PropConstraintScan;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.Map;



@Controller
@RequestMapping("/module/propertyConstraintBean")
public class PropConstraintController {

    private String prefix = "module/propertyConstraint";

    @Autowired
    PropConstraintScan propConstraintScan;

    @RequestMapping("/lookupListData")
    @ResponseBody
    public Collection<PropConstraintVO>  propertyConstraint(){
        Map<String, PropConstraintVO> propConstraints = propConstraintScan.getPropConstraints();
        Collection<PropConstraintVO> values = propConstraints.values();
        return values;
    }



    /**
     * 接口项目中选择域名
     */
    @GetMapping("/lookupList")
    public String lookupList(@RequestParam(value = "beanKey",required = false) String beanKey, ModelMap mmap)
    {
        //为空时,
        if(!StringUtils.isBlank(beanKey)){
            mmap.put("baseModel", propConstraintScan.getPropConstraints().get(beanKey));
        }
        return prefix + "/beanLookup";
    }
}
